import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
import Cookie from '../cookies/cookie'
Vue.use(VueRouter)



const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach((to, form, next) => {
  let cookie = Cookie.getCookie()
  if (!cookie._login && to.path != '/login' && to.path != '/register') {
    next('/login')
  } else {
    next()
  }
})

export default router
